 <?php
 /*取得 网站导航栏*/
function getHomeNavs($typeId=0)
{
    $navList = R("Content/obj/navTree");
    $tree=array();
    if (!empty($navList)) 
    {
        foreach ($navList as $key => $nav) 
        {
            if ($nav['typeid'] > 0 ) 
            {
                $url=R("Content/obj/getTypeUrlById",array($nav['typeid']));
                if ($typeId>0) {
                    $parentTypeId = R("Content/obj/getParentTypeIdByTypeId",array($typeId));
                }else{
                    $parentTypeId = 0;
                }
                $active = ($nav['typeid']==$parentTypeId)? "active" : "";
            }else{
                $url = $nav['url'];
                $active = ($url==$_SERVER['REQUEST_URI'])? "active" : "";
            }
            $nav['active']=$active;
            $nav['url']=$url;
            $id = $nav["id"];
            $parentId=$nav['parentid'];
            $sort = $nav["sort"];
            if($sort>0){
                $tree[$parentId]['child'][]=$nav;
            }else{
                $tree[$id]=$nav;
            }
        }
    }        
    return $tree;
}
/*根据文章的id获得文章的基本信息*/
function getArticleById($articleId=0)
{
    if($articleId>0)
    {
        $articleObj= R("Content/obj/getArticleById",array($articleId));
        if(!empty($articleObj)){
            return $articleObj;
        }else{
            return null;
        }
    }else{
        return null;
    }
}
/*文章的id获得文章的文章详情信息*/
function getArticleDetailById($articleId=0)
{
    if($articleId>0)
    {
        $article_detailObj= R("Content/obj/getArticleDetailById",array($articleId));
        if(!empty($article_detailObj)){
            return $article_detailObj;
        }else{
            return null;
        }
    }else{
        return null;
    }
}
/*根据文章的id获得文章的标题*/
function getArticleTitleById($articleId=0)
{
    if($articleId>0)
    {
        $article_titleObj= R("Content/obj/getArticleTitleById",array($articleId));
        if(!empty($article_titleObj)){
            return $article_titleObj;
        }else{
            return null;
        }
    }else{
        return null;
    }
}
/*根据栏目的id获得文章列表:*/
function getArticleByTypeId($typeId=0,$limit=10)
{
    if($typeId>0)
    {
        $articleObjs= R("Content/obj/getArticleByTypeId",array($typeId,$limit));
        if(!empty($articleObjs)){
            return $articleObjs;
        }else{
            return null;
        }
    }else{
        return null;
    }
}
/*根据查询条件获得文章列表:*/
function getArticleByCondition($field='id,title',$where=array(), $order=array(),$limit=15)
{
    $articleObjs= R("Content/obj/getArticleByCondition",array($field,$where,$order,$limit));
    if(!empty($articleObjs)){
        return $articleObjs;
    }else{
        return null;
    }
}
function getArticleListByParentId($parentId=0)
{
    if($parentId>0)
    {
        $articleObjs= R("Content/obj/getArticleListByParentId",array($parentId));
        if(!empty($articleObjs)){
            return $articleObjs;
        }else{
            return null;
        }
    }else{
        return null;
    }
}
function getArticleByIdArr($ids='')
{
    if(!empty($ids))
    {
        $articleObjs= R("Content/obj/getArticleByIdArr",array($ids));
        if(!empty($articleObjs)){
            return $articleObjs;
        }else{
            return null;
        }
    }else{
        return null;
    }
}
function getArticleListByArticleIdTypeId($articleId=0,$typeId=0)
{
    if($articleId>0&&$typeId>0)
    {
        $articleObjs= R("Content/obj/getArticleListByArticleIdTypeId",array($articleId,$typeId));
        if(!empty($articleObjs)){
            return $articleObjs;
        }else{
            return null;
        }
    }else{
        return null;
    }
}
/*param artileId result 文章封面图*/
function getFrontImageByArtileId($articleId=0)
{
    if($articleId>0)
    {
        $frontImageObj= R("Content/obj/getFrontImageByArtileId",array($articleId));
        if(!empty($frontImageObj)){
            return $frontImageObj;
        }else{
            return null;
        }
    }else{
        return null;
    }
}
function getArticleImageByArtileId($articleId=0)
{
    if($articleId>0)
    {
        $articleImageObjs= R("Content/obj/getArticleImageByArtileId",array($articleId));
        if(!empty($articleImageObjs)){
            return $articleImageObjs;
        }else{
            return null;
        }
    }else{
        return null;
    }
}

function getImageByImageId($imageId=0)
{
    if($imageId>0)
    {
        $imageObj= R("Content/obj/getImageByImageId",array($imageId));
        if(!empty($imageObj)){
            return $imageObj;
        }else{
            return null;
        }
    }else{
        return null;
    }
}
function getAttributeByMark($mark,$articleId=0)
{
    if($articleId>0)
    {
        $attributeValue= R("Content/obj/getAttributeByMark",array($articleId,$mark));
        if(!empty($attributeValue)){
            return $attributeValue;
        }else{
            return null;
        }
    }else{
        return null;
    }
}
/*返回 幻灯片集合*/
function getSlides()
{
    $slideObjs= R("Content/obj/getSlides");
    if(!empty($slideObjs)){
        return $slideObjs;
    }else{
        return null;
    }
}
/*返回当前的所属分类 */
function getTypeByTypeId($typeId=0)
{
    if($typeId>0)
    {
        $typeObjs= R("Content/obj/getTypeByTypeId",array($typeId));
        if(!empty($typeObjs)){
            return $typeObjs;
        }else{
            return null;
        }
    }else{
        return null;
    }
}

/**/
function getChildTypeByParentId($parentId=0)
{
    if($parentId>0)
    {
        $typeObjs= R("Content/obj/getChildTypeByParentId",array($parentId));
        if(!empty($typeObjs)){
            return $typeObjs;
        }else{
            return null;
        }
    }else{
        return null;
    }

}
function getTypeNameById($typeId=0)
{
    if($typeId>0)
    {
        $typeObj= R("Content/obj/getTypeById",array($typeId));
        if(!empty($typeObj)){
            return $typeObj['name'];
        }else{
            return null;
        }
    }else{
        return null;
    }
}

function getLeavemessageByCondition($field='id,title',$where=array(), $order=array(),$limit=15)
{
    $leavemessageObjs= R("Content/obj/getLeavemessageByCondition",array($field,$where,$order,$limit));
    if(!empty($leavemessageObjs)){
        return $leavemessageObjs;
    }else{
        return null;
    }
}
function getArticleMemberNum($articleId){
    if($articleId>0)
    {
        $mcount= R("Content/obj/getArticleMemberNum",array($articleId));
        return $mcount;
        
    }else{
        return "0";
    }
}
function getArticleMemberByArticleId($articleId){
    if($articleId>0)
    {
        $articleMemberObjs= R("Content/obj/getArticleMemberByArticleId",array($articleId));
        return $articleMemberObjs;
        
    }else{
        return null;
    }
}
function getArticleIdsByTypeId($typeId){
    if(!empty($typeId))
    {
        $articleIdsStr= R("Content/obj/getArticleIdsByTypeId",array($typeId));
        return $articleIdsStr;
    }else{
        return "0";
    }
}

function getArticleMemberCountInArticleIds($articleIds){
    if(!empty($articleIds))
    {
        $articleMemberCount= R("Content/obj/getArticleMemberCountInArticleIds",array($articleIds));
        return $articleMemberCount;
    }else{
        return "0";
    }
}
function getAttributesByTypeId($typeId){
    if(!empty($typeId))
    {
        $attributes= R("Content/obj/getAttributesByTypeId",array($typeId));
        return $attributes;
    }else{
        return null;
    }
}
function getMemberPoints($memberId){
    $points= R("Content/obj/getMemberPoints",array($memberId));
    return $points;  
}
function getMemberListOrder($limit){
    $members= R("Content/obj/getMemberListOrder",array($limit));
    return $members;  
}
?>